import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;

public class GuiExecutor extends AbstractExecutorService {
    // 采用“单件（Singletion）模式，有一个私有构造函数和一个共有的工厂方法
    private static final GuiExecutor instance = new GuiExecutor();

    private GuiExecutor() {

    }

    public static GuiExecutor instance() {
        return instance;
    }

    public void execute(Runnable r) {
        if (SwingUtilies.isEventDispatchThread())
            r.run();
        else
            SwingUtilities.invokeLater(r);
    }

    @Override
    public void shutdown() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'shutdown'");
    }

    @Override
    public List<Runnable> shutdownNow() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'shutdownNow'");
    }

    @Override
    public boolean isShutdown() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'isShutdown'");
    }

    @Override
    public boolean isTerminated() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'isTerminated'");
    }

    @Override
    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'awaitTermination'");
    }
}